package com.lwq.util;

public class PreferencesUtil {
	private static PreferencesUtil instance = null;
	private PreferencesConfig Config = null;
	private String configPath = null;
	public PreferencesUtil(String cfgPath){
		configPath = cfgPath;
		if(configPath != null){
			Config = (PreferencesConfig)GsonUtil.getInstance(GsonUtil.BUILD_TYPE).FileToModel(configPath, PreferencesConfig.class);
		}
	}
	
	public PreferencesConfig getConfig() {
		return Config;
	}

	public static PreferencesUtil getInstance() {
		if(instance == null){
			instance = new PreferencesUtil(Constance.PREFERENCES_CONFIG_PATH);
		}
		return instance;
	}
	
	public void saveConfig() {
		if(Config != null){
			GsonUtil.getInstance(GsonUtil.BUILD_TYPE).modelToFile(Config, configPath);
		}
	}
	
	public class PreferencesConfig{
		private String openFilePath = null;
		public PreferencesConfig(){
			
		}
		public String getOpenFilePath() {
			return openFilePath;
		}
		public void setOpenFilePath(String openFilePath) {
			this.openFilePath = openFilePath;
		}
		
	}
}
